﻿#region Copyright (C) Sector7 Software Studio. All rights reserved
/*******************************************************************************************
 * Creation
 *      Author:         Wolf Lai
 *      Date:           2013/2/18 星期一 23:43:22
 *      Version:        
 * Modification 
 *      Author: 
 *      Date: 
 *      Description: 
 *      Version:
 *******************************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sector7.Framework.Core;

namespace Sector7.Framework.DB
{
    /// <summary>
    /// 数据访问接口基类
    /// </summary>
    /// <typeparam name="T">实体类型</typeparam>
    public interface IDAOBase<T> where T : class
    {
        /// <summary>
        /// 创建实体信息
        /// </summary>
        /// <param name="entity">实体信息</param>
        /// <returns></returns>
        object Create(T entity);

        /// <summary>
        /// 批量创建实体信息
        /// </summary>
        /// <param name="entityList">实体列表</param>
        /// <returns></returns>
        int CreateAll(List<T> entityList);

        /// <summary>
        /// 通过实体主键读取实体信息
        /// </summary>
        /// <param name="primaryKey">实体主键</param>
        /// <returns></returns>
        T Read(object primaryKey);

        /// <summary>
        /// 读取实体列表
        /// </summary>
        /// <returns></returns>
        List<T> ReadAll();

        /// <summary>
        /// 更新实体信息
        /// </summary>
        /// <param name="delta">改变量</param>
        /// <returns>操作结果</returns>
        int Update(EntityDeltaBase delta);

        /// <summary>
        /// 删除实体信息
        /// </summary>
        /// <param name="primaryKey">实体主键</param>
        /// <returns>操作结果</returns>
        int Delete(object primaryKey);
    }
}
